package com.nbjtjc.safe.job.task;

import cn.hutool.core.util.ObjectUtil;
import com.nbjtjc.safe.bean.Constant;
import com.nbjtjc.safe.mapper.emg.EmgWorkBriefMapper;
import com.nbjtjc.safe.model.emg.EmgWorkBrief;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @auther guqianbin
 * @date 2018/7/26 10:11
 **/
@Component("workBriefTask")
public class SendWorkBriefTask {
    private Logger logger = LoggerFactory.getLogger(SendWorkBriefTask.class);

    @Autowired
    private EmgWorkBriefMapper emgWorkBriefMapper;

    public void sendWorkBrief(String workBriefId,Integer jobId){
        logger.info("要被发送的工作简报的id：" + workBriefId);
        try {
            EmgWorkBrief emgWorkBrief=emgWorkBriefMapper.selectByPrimaryKey(Integer.parseInt(workBriefId));
//            if(ObjectUtil.isNotNull(emgWorkBrief)
//                    &&emgWorkBrief.getStatus().equals(Constant.WorkBriefStatus.UNPUBLIC.getValue())){
//                emgWorkBrief.setReportTime(new Date());
//                emgWorkBrief.setStatus(Constant.WorkBriefStatus.PUBLIC.getValue());
//                emgWorkBriefMapper.updateByPrimaryKeySelective(emgWorkBrief);
//            }else{
//                logger.error("要被发送的工作简报的id：" + workBriefId+"数据库中没有该id的对象");
//            }
        } catch (NumberFormatException e) {
            e.printStackTrace();
            logger.error("指定发送简报的定时任务发生错误 ，需要发送的workBriefId："+workBriefId,e);
        }
    }
}
